import request from "./request/index.js";

export async function addSalesOrder(data) {
  try {
    const res = await request.post("/sales-order", data);
    return res.data;
  } catch (err) {
    return Promise.reject(err);
  }
}

export async function listSalesOrders(data) {
  try {
    const res = await request.post("/sales-order/list", data);
    return res.data;
  } catch (err) {
    return Promise.reject(err);
  }
}

export async function getSalesOrder(id) {
  try {
    const res = await request.get(`/sales-order/${id}`);
    return res.data;
  } catch (err) {
    return Promise.reject(err);
  }
}

export async function updateSalesOrder(data) {
  try {
    const res = await request.put('/sales-order', data);
    return res.data;
  } catch (err) {
    return Promise.reject(err);
  }
}

export async function redSalesOrder(id) {
  try {
    const res = await request.post(`/sales-order/red/${id}`);
    return res.data;
  } catch (err) {
    return Promise.reject(err);
  }
}
